package com.zzw.hj19;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 简单错误记录
 * @Author: zzw
 */

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        HashMap<String, Integer> map = new HashMap<>();
        ArrayList<String> keyOrder = new ArrayList<>();
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String[] input = in.nextLine().split(" ");
            String[] arrKey = input[0].split("\\\\");
            String key = arrKey[arrKey.length - 1];
            if (key.length() > 16) {
                key = key.substring(key.length() - 16);
            }
            key = key + " " + input[1];

            if (map.get(key) == null) {
                map.put(key, 1);
                keyOrder.add(key);
            } else {
                map.put(key, map.get(key) + 1);
            }
        }

        int i = 0;
        if (keyOrder.size() > 8) {
            i = keyOrder.size() - 8;
        }
        for (; i < keyOrder.size(); i++) {
            System.out.println(keyOrder.get(i) + " " + map.get(keyOrder.get(i)));
        }
    }
}